package main

import (
	"fmt"
	"sync"
)

func main() {
	c1 := make(chan int, 5)
	//5是channel缓冲容量
	go func() {
		for i := 0; i < 10; i++ {
			c1 <- i
		}
	}()
	//channel 会一直维持满的状态，直到没有输入则一直取出到空
	for i := 0; i < 10; i++ {
		fmt.Println(<-c1)
	}
}
func routine() {
	var wg sync.WaitGroup
	wg.Add(1)
	go Run(&wg)
	wg.Wait()
}

func Run(wg *sync.WaitGroup) {
	fmt.Println("working !")
	wg.Done()
}
